//
//  NSInvocationAdditions.h
//  HigherOrderMessaging
//
//  Created by Ofri Wolfus on 24/09/05.
//  Copyright 2005 Ofri Wolfus. All rights reserved.
//

#import <Foundation/NSInvocation.h>
#import <HigherOrderMessaging/Message.h>


/*!
 * @category NSInvocation (HOMAdditions)
 * @abstract Adds some convenient methods to NSInvocation.
 */
@interface NSInvocation (HOMAdditions)

/*!
 * @method returnValue
 * @abstract Returns the return value of the receiver.
 * @discussion If the return value is an object, it'll just be returned. If it's something else, HOMObjCValue instance will be returned.
 */
- (id)returnValue;

/*!
 * @abstract Returns a Message instance that matches the receiver.
 */
- (Message *)message;

@end

/*!
 * @category NSInvocation (HOMCopying)
 * @abstract Implements the NSCopying protocol for NSInvocation.
 * @discussion This category implements the NSCopying protocol for NSInvocation.
 */
@interface NSInvocation (HOMCopying) <NSCopying>

- (id)copyWithZone:(NSZone *)zone;

@end

#define DPMakeInvocation(target, message...) \
({ \
	id __builder = [(id)objc_getClass("HOMInvocationBuilder") builderForTarget:target]; \
	NSInvocation *__inv = ID([__builder message]); \
	[__builder dealloc]; \
	__inv; \
})
